package bos.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import bos.dao.IFunctionDao;
import bos.domain.Function;
import bos.domain.User;
import bos.service.IFunctionService;
import bos.utils.BOSContext;
import bos.utils.PageBean;

@Service
@Transactional
public class FunctionServiceImpl implements IFunctionService{
@Autowired
private IFunctionDao functiondao;

@Override
public void pageQuery(PageBean pageBean) {
	functiondao.pageQuery(pageBean);
}

@Override
public List<Function> findAll() {
	return functiondao.findAll();
}

@Override
public void save(Function model) {
	Function function=model.getFunction();
	if(function !=null&&function.getId().equals("")){
		model.setFunction(null);
	}
	functiondao.save(model);
}

@Override
public List<Function> findMenu() {
	User user=BOSContext.getLoginUser();
	List<Function> list=null;
	if(user.getUsername().equals("jack")){
		list=functiondao.findAllMenu();
	}else{
		list=functiondao.findMenuByUserid(user.getId());
		
	}
	return list;
}

}
